<link href="./css/style.css" rel="stylesheet" type="text/css" />
<div class="main">
<div class="cate">
	<p class="tt"><a>首页</a>><a href="newslist.php">资讯管理</a>><span>分类管理</span><a style="float:right; margin-right:10px;" href="menu.php?act=add">添加分类</a></p>
	{if($msg==1)}
	<form class="cateadd">		
		<p class="p1"><span>分类名称</span><input type="text" name="t0" placeholder="请输入分类名称" /></p>
		<p class="p2"><span>分类目录</span><input type="text" name="t1" placeholder="备选项" /></p>
		<p class="p1"><span>导航显示</span><select name="t2"><option value='1'>是</option><option value='0'>否</option></select></p>
		<p class="p1"><span>栏目排序</span><input type="text" name="t3" placeholder="越大越靠前" /></p>
		<button type="button" class="tj" onclick="cateadd();">确认添加</button>
	</form>
	{elseif($msg==2)}
	<form class="catedit">
		<input type="hidden" value="{$info[Id]}" name="id" />		
		<p class="p1"><span>分类名称</span><input type="text" name="t0" placeholder="请输入分类名称" value="{$info[name]}" /></p>
		<p class="p2"><span>分类目录</span><input type="text" name="t1" placeholder="备选项" value="{$info[dirname]}" /></p>	
		<p class="p1"><span>导航显示</span><select name="t2">
			<option value='0' {if($info['menu']==0)}selected{/if}>否</option>
			<option value='1' {if($info['menu']==1)}selected{/if}>是</option>
		</select></p>
		<p class="p1"><span>栏目排序</span><input type="text" name="t3" placeholder="越大越靠前" value="{$info[px]}" /></p>
		<button type="button" class="tj" onclick="catedit();">确认修改</button>
	</form>
	{else}
	<div class='menu'>
		<div class='fl1'>
			<p class='bt1'>资讯分类</p>
			<table>				
				<tr class='li1'><th>名称</th><th>目录</th><th>导航</th><th>操作</th></tr>
				{loop $cat1 $key as $list}
				<tr >
					<td><a class="a" href="newslist.php?catid={$list[Id]}">{$list[name]}</a></td>
					<td><span class="s1">{$list[dirname]}</span></td>
					<td><span class="s1">{$menu[$list[menu]]}</span></td>
					<td><span class="s4"><a class="a1" href="menu.php?id={$list[Id]}&act=add">编辑</a></span></td>
				</tr>
				{/loop}
			</table>
		</div>		
	</div>
	{/if}
	<script src="./js/jquery.js"></script>
	<script>		
		function cateadd(){
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=n&a=menuadd",
					data:$(".cateadd").serialize(),
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='menu.php';
						}
					}
				});
			}
			function catedit(){
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=n&a=menuedit",
					data:$(".catedit").serialize(),
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='menu.php';
						}
					}
				});
			}
			
	</script>
	
</div>
</div>
<script>
	h1 = $(".main").height();
	h2 = $(".cate").height();
	if(h2>h1){
		$(".main").css("height","auto");
	}
</script>
